
var UvUrl= window.location.pathname,
host_ = window.location.host,
isLoading = false, //正在加载
isOver = false, //是否结束直播

all = {leftHeight: 0, rightHeight: 0, theLast: 0, theNew: 0, newImgArr: [], fixLocation: [], preloadImg: [], swiperArr: []}, //默认全部 对象
hot = {fixLocation: [], preloadImg:[], swiperArr:[]}, // 热门 对象
timeLine = {fixLocation: [], preloadImg: [], swiperArr: [], count: 0, step: 3, add: 0, data: [], theme: 1}, // 时间线对象 ,theme: 区分黑白版本
imageText = {fixLocation: [], preloadImg: [], swiperArr: [], count: 0, step: 50, add: 0, data: [], theme: 1, bol: false, has: false}, // 图文对象  bol: 是否切换到在图文 has: 是否有图文

picStep = 30, // （全部、分相册）每次加载的数量
picAllNum = 0, // 图片总数
theRefreshNum = 0, //新图总数
winH = $(window).height(),
$document = $(document),

albumNav_st = 0,
whSt = 0, // 微吼视频滚动高度
whUrl = '', // 微吼视频链接

picShowSwiper, // 大图预览
albumArr = [], //储存每个相册信息的数组
scrollEle = '.all', //滚动哪个区块
scrollObj = all, //滚动哪个区块的对象
albumsInterval, //在哪个相册只检测该相册是否更新
refreshTimer, // 轮询检测图片是否有更新
findMeBol = true, // 是否有找自己引导
findMeUp,       //七牛上传实例
likeArr = [], // 点赞喜欢的数组
picLikeArr = [], //所有自己点过赞的图片hash数组
bigTagArr = [], // 1-10排名的hash数组
hotTab = false, // 是否是在热门的tab下操作

shareImgUrl = '', //分享的链接
sharedescContent = '', //分享的内容
shareTitle = '', //分享的标题

puzzledCount = 0, // 选择拼图的数量
puzzledStatus = false, //是否在拼图的状态

activityNo = getNo(), // 获取activityNo;
user_id = getCookie('user_id'), // user id

pravite_password = '', // 私密活动的密码

homeGuide_ = getCookie('home_guide'),

clickGuide = homeGuide_ === 'false' ? true : false,
clickStart = false,
clickPass = false;

// 初始化
$(init);

// 初始化
function init() {
  // ***********************************************
  $('.me').addClass('none');
  // ***********************************************

  // 密码确认
  $('#password-enter').click(praviteVerify);
  // 点击跳过主视觉
  $('.main-view-enter').click(function() {
    $('.main-masking').fadeOut(1000);
    addWhUrl(2);
  })
  // 取消引导页
  $('#guideModal').click(removeHomeGuide);
  // 点击出现详情
  $('.activityDetail-button').click(activityInfoAlert);
  // 点击主办方和嘉宾
  $('.guestWrapper').on('click', '.sponsor', {type: 'sponsor'}, activityGuestAlert);
  $('.guestWrapper').on('click', '.guest', {type: 'guest'}, activityGuestAlert);
  // 关闭弹层
  $('.close').on('click', activityCloseAlert);
  // 切换相册

  $('.nav').on('click', '.navLi', switchAlbumTab);

  // 切换图片展示方式（瀑布流，平铺）
  $('.changeStyle').on('click', 'span', switchPicDisplay);
  // 点击图片 展示大图
  $('.photoWrapper').on('click', '.picItem', bigPicShow);
  // 关闭大图预览
  $('.modalClose').click(closeBigPicShow);

  // 开启拼图模式
  $('#puzzle').on('click', {bol: true}, ifPuzzled);
  // 关闭拼图模式
  $('.puzzle-cancel').on('click', {bol: false}, ifPuzzled);
  // 去拼图确认
  $('.puzzle-sure').click(getPuzzle);
  // 关闭拼图
  $('.puzzled-result-close').click(closePuzzleAlert);
  // 选择将要拼图的图片
  $('.picContainer').on('click', '.picSelect', selectPuzzlePic);
  // 时间线 收缩
  $('.timeLine').on('click', '.timeLine-title', shrinkTimeLine);
  // 找自己
  $('.findMe').click(findMeFloat);
  $('.find-button').click(findMeGuide);
  // 聚合页
  $('.jh-button').click(gatherEntry);
  // 点赞
  $('.like').click(clickLikes);
  // 单张分享按钮
  $('.singleShare-box').on('click', {bol: true}, singleShare);
  $('#share').on('click', {bol: false}, singleShare);
  // 请求原图
  $('.originPic-box').click(requestOriPic);
  // 滚动行为
  $document.on('scroll', scrollAction);

  findMeUp = new QiniuJsSDK(); // 初始化找自己
  homeGuide(); //引导页 是否出现
  getGuest(); // 获得嘉宾列表信息
  getAlbum(); // 获得相册nav
  getDetail('.all', all); // 获得详情、状态等信息
  logoPos2(); // 判断 powered by pushi的位置
  getLikes(); // 获得点赞的数组

  picTimer(); //定时刷新全部

  if($('.navLi').eq(0).find('.navLi-span').hasClass('white')) {
    $('.navLi').eq(0).find('.navLi-span').css({'color':'#333', 'border-bottom-color':'#333'});
  } // 有空优化

  albumNav_st = $('.nav').offset().top; // 相册栏距顶部高度

  addWhUrl(4);
}
function activityInfoAlert() {
  // 切换时关闭拼图模式
  $('.puzzle-cancel').trigger('click');
  $('video').addClass('none');
  $('#mesModal').fadeIn();

  whModify();
}
function activityGuestAlert(event) {
  var guestType = event.data.type;
  var $this = $(this);
  var qrcode = $this.attr('data-qr');
  var link = $this.attr('data-link');

  $('.puzzle-cancel').trigger('click');
  $('video').addClass('none');

  whModify();

  if (guestType === 'sponsor') {
    $('#holderModal').fadeIn();
    $('.sponsor-img').attr('src', $this.attr('data-logo'));
    $('.sponsor-name').html($this.attr('data-name'));
    $('.sponsor-describe').html($this.attr('data-describe'));
    $('.sponsor-link').attr('href', link);
    $('.sponsor-qrcode').find('img').attr('src', qrcode);
    removeEle(qrcode, '.sponsor-qrcode');
    removeEle(link, '.sponsor-link');
  } else if (guestType === 'guest') {
    $('#guestModal').fadeIn();
    $('.guest-img').attr('src', $this.attr('data-logo'));
    $('.guest-name').html($this.attr('data-name'));
    $('.guest-describe').html($this.attr('data-describe'));
    $('.guest-link').attr('href', link);
    $('.guest-qrcode').find('img').attr('src', qrcode);
    removeEle(qrcode, '.guest-qrcode');
    removeEle(link, '.guest-link');
  }
}
function activityCloseAlert() {
  $('#holderModal, #guestModal, #mesModal, .find-container, #guideModal, .try-wrapper, .appointment-wrap, .order-wrapper').fadeOut();
  $('video').removeClass('none');
  $('body').css('position', 'relative');
}
// 切换相册tab
function switchAlbumTab() {
  var $this = $(this);
  var li_index = $this.index();
  var navSpan = $this.find('.navLi-span');
  var isActive = navSpan.hasClass('navLiActive');
  var albumId = $this.attr('data-id'); //相册的id
  var noRedDot = $this.find('.btn-refresh').hasClass('none');
  hotTab = false;

  // 切换时关闭拼图模式
  $('.puzzle-cancel').trigger('click');

  // 清除红点
  $this.find('.btn-refresh').addClass('none');

  // 切换nav的样式
  $('.navLi').find('.navLi-span').removeClass('navLiActive');
  navSpan.addClass('navLiActive');
  if(navSpan.hasClass('white')) {
    $('.navLi').find('.navLi-span').css({'border-bottom-color':'transparent', 'color':'#6b6d70', 'font-weight':'normal'})
    navSpan.css({'border-bottom-color':'#333', 'color':'#333', 'font-weight':'700'});
  }
  // 滚动至顶部
  var photoWrapper_st = $('.photoWrapper').offset().top - 15;
  $('body').animate({scrollTop: photoWrapper_st},400);

  // 所有相册都隐藏
  $('.block').addClass('none');
  // 判断相册的显示状态
  if (albumId == 0) {
    $('.all').removeClass('none');
    scrollEle = '.all';
    scrollObj = all;
    if (imageText.has && imageText.bol) getImageTextPics();
  } else if (albumId == 'hot') {
    $('.hot').removeClass('none');
    scrollEle = '.hot';
    scrollObj = hot;
    hotTab = true; //用于热门图片点开大图 有个排名的标识
    getHotPics();
  } else if (albumId == 'timeline') {
    $('.timeLine').removeClass('none');
    scrollEle = '.timeLine';
    scrollObj = timeLine;
    getTimelinePics();
  } else {
    picStep = 30; //更新相册初始加载数量
    $('.album' + albumId).removeClass('none');
    scrollEle = '.album' + albumId;
    scrollObj = albumArr[li_index - 3];

    $(scrollEle).find('.picLoadingBottom').animate({height: 50},200);

    clearInterval(albumsInterval); //取消上一个定时器
    albumInterVal($this, scrollObj, albumId); // 开启相应相册对应的定时器

    if (!scrollObj.albumNew) {
      getAlbumPics(scrollEle, scrollObj);
      scrollObj.albumNew = true;
    }
  }

  // 判断相册是否要更新
  if (li_index == 0 && !noRedDot) {
    refreshPics(scrollEle, scrollObj);
  } else if (li_index > 1 && !noRedDot) {
    albumRefreshPics(scrollEle, scrollObj);
  }
}
// 切换展示方式
function switchPicDisplay() {
  // 关闭拼图模式
  $('.puzzle-cancel').trigger('click');

  var index = $(this).index();
  $('.changeStyle span').removeClass('active');

  if (index === 0) {
    $('.changeStyle span').eq(0).addClass('active');
    $('.tiledContainer').addClass('none');
    $('.fourImageContainer').addClass('none');
    $('.waterFallContainer').find('.picLeft').removeClass('none');
    $('.waterFallContainer').find('.picRight').removeClass('none');
    $('.waterFallContainer').css('width', '100%');
    imageText.bol = false;
  } else {
    $('.changeStyle span').eq(1).addClass('active');
    $('.waterFallContainer').css('width', '0');
    $('.waterFallContainer').find('.picLeft').addClass('none');
    $('.waterFallContainer').find('.picRight').addClass('none');
    $('.tiledContainer').removeClass('none');
    $('.fourImageContainer').eq(1).addClass('none');
    $('.fourImageContainer').eq(0).removeClass('none');
    // 如果有图文 切换时展示图文
    imageText.bol = true;
    if (imageText.has && imageText.bol) {
      getImageTextPics();
    }
  }
}
// 点开大图
function bigPicShow() {
  whModify();

  $(document).on('touchmove', touchModal);
  $('video').addClass('none');
  var getOri = $('#imgShowModal .swiper-slide-active img').attr('data-getOri');
  getOri === 'yes' ? $('#origin-picSize').addClass('none') : $('#origin-picSize').removeClass('none');

  var $this = $(this);
  var likeCount_ = $this.attr('data-likeCount'); //喜欢改图的数量
  var thisHash = $this.attr('data-hash'); //hash
  var thisSrc = $this.attr('data-src') || $this.attr('src');
  var showIndex = scrollObj.fixLocation.indexOf(thisSrc);
  var showNum = scrollObj.fixLocation.length;
  var add = showIndex, reduce = showIndex, oneOrTwo = 0, dom = '';
  var midsize_ = $this.attr('data-midSize');
  var orisize_ = $this.attr('data-oriSize');
  var time = $(this).attr('data-time');
  midsize_ = ((midsize_/(1024*1024)) >= 1) ? (midsize_/(1024*1024)).toFixed(1)+"MB" : parseInt(midsize_/1024)+"KB";
  orisize_ = ((orisize_/(1024*1024)) >= 1) ? (orisize_/(1024*1024)).toFixed(1)+"MB" : parseInt(orisize_/1024)+"KB";
  $('#picSize').html('目前大小'+midsize_);
  $('#origin-picSize').html('，原图' + orisize_);
  $('#pub-time').html(time);
  $('#like-num').html(likeCount_);

  likeStatus(likeCount_);

  testLike(thisHash); // 自己是否点过赞

  dom = '\
  <div class="swiper-slide">\
  <div class="slide_zoom_container row-all-center" style="height: '+ winH +'px">\
  <img class="swiper-lazy big_img_slide" data-src="'+ scrollObj.swiperArr[showIndex].big_img +'" data-hash="'+ scrollObj.swiperArr[showIndex].pic_hash +'" data-midSize="'+ scrollObj.swiperArr[showIndex].middle_size +'"\
  data-time="'+ scrollObj.swiperArr[showIndex].create_time +'" data-ori="'+ scrollObj.swiperArr[showIndex].origin_img +'" data-oriSize="'+ scrollObj.swiperArr[showIndex].pic_size +'" data-likeCount="'+ scrollObj.swiperArr[showIndex].like_count +'" onload=loadOnePic(this)>\
  </div>\
  </div>';
  $('.imgShowSwiper .swiper-wrapper').append(dom);
  picShowSwiper = new Swiper('.imgShowSwiper', {
    centeredSlides: true,
    preloadImages: false,
    lazyLoading: true,
    observer: true,
    initialSlide: oneOrTwo,
    onInit: function() {
      var father = $('.imgShowSwiper');
      var thisBigImg = $('.imgShowSwiper .swiper-slide-active .big_img_slide');
      var hash_ = thisBigImg.attr('data-hash');
      // 查看记录hash
      picAjax('pic_view', hash_);
      // 长按记录hash
      thisBigImg.longPress(function(){picAjax('pic_down', hash_);});
      touchImg(thisBigImg, father); //下拉或上拉  关闭预览
      testBigTag(hash_); //大图是否有排名标签
    },
    onSlideChangeStart: function() {
      $('.common-loading').addClass('none');

      var father = $('.imgShowSwiper');
      var thisBigImg = $('.imgShowSwiper .swiper-slide-active .big_img_slide');
      var hash_ = thisBigImg.attr('data-hash');
      var midsize_ = thisBigImg.attr('data-midSize');
      var orisize_ = thisBigImg.attr('data-oriSize');
      var time = $(this).attr('data-time');
      var getOri = $('#imgShowModal .swiper-slide-active img').attr('data-getOri');

      if(getOri == 'yes') {
        midsize_ = thisBigImg.attr('data-oriSize');
        $('#origin-picSize').addClass('none');
      } else {
        $('#origin-picSize').removeClass('none');
      }
      midsize_ = ((midsize_/(1024*1024)) >= 1) ? (midsize_/(1024*1024)).toFixed(1)+"MB" : parseInt(midsize_/1024)+"KB";
      orisize_ = ((orisize_/(1024*1024)) >= 1) ? (orisize_/(1024*1024)).toFixed(1)+"MB" : parseInt(orisize_/1024)+"KB";

      $('#picSize').html('目前大小'+midsize_);
      $('#origin-picSize').html('，原图' + orisize_);
      $('#pub-time').html(time);
      testLike(hash_); // 自己是否点过赞

      picAjax("pic_view", hash_);
      thisBigImg.longPress(function(){picAjax("pic_down", hash_);});

      touchImg(thisBigImg, father); //下拉或上拉  关闭预览
      testBigTag(hash_); //大图是否有排名标签
      //利用hash去获得列表中likecount的数量 方法不好 暂用
      $(scrollEle).find('.picItem').each(function() {
        var $this_ = $(this);
        var thisHash = $this_.attr('data-hash');
        if(thisHash == hash_) {
          var thisCount = $this_.attr('data-likeCount');
          $('#like-num').html(thisCount);
          likeStatus(thisCount);
        }
      })
    },
    onSlidePrevEnd: function(swiper) {
      reduce--;
      if(reduce >= 0) {
        var dom = '\
        <div class="swiper-slide">\
        <div class="slide_zoom_container row-all-center" style="height: '+ winH +'px">\
        <img class="swiper-lazy big_img_slide" data-src="'+ scrollObj.swiperArr[reduce].big_img +'" data-hash="'+ scrollObj.swiperArr[reduce].pic_hash +'" data-midSize="'+ scrollObj.swiperArr[reduce].middle_size +'"\
        data-time="'+ scrollObj.swiperArr[reduce].create_time +'" data-ori="'+ scrollObj.swiperArr[reduce].origin_img +'" data-oriSize="'+ scrollObj.swiperArr[reduce].pic_size +'" data-likeCount="'+ scrollObj.swiperArr[reduce].like_count +'" onload=loadOnePic(this)>\
        </div>\
        </div>';
        picShowSwiper.prependSlide(dom);
        picShowSwiper.update(true);

      }
      var $this = $('.imgShowSwiper .swiper-slide-prev .slide_zoom_container');
      new RTP.PinchZoom($this, {});
    },
    onSlideNextStart: function() {
      add++;
      if(add < showNum) {
        var dom = '\
        <div class="swiper-slide">\
        <div class="slide_zoom_container row-all-center" style="height: '+ winH +'px">\
        <img class="swiper-lazy big_img_slide" data-src="'+ scrollObj.swiperArr[add].big_img +'" data-hash="'+ scrollObj.swiperArr[add].pic_hash +'" data-midSize="'+ scrollObj.swiperArr[add].middle_size +'"\
        data-time="'+ scrollObj.swiperArr[add].create_time +'" data-ori="'+ scrollObj.swiperArr[add].origin_img +'" data-oriSize="'+ scrollObj.swiperArr[add].pic_size +'" data-likeCount="'+ scrollObj.swiperArr[add].like_count +'" onload=loadOnePic(this)>\
        </div>\
        </div>';
        picShowSwiper.appendSlide(dom);
        picShowSwiper.update(true);

      }
      var $this = $('.imgShowSwiper .swiper-slide-next .slide_zoom_container');
      new RTP.PinchZoom($this, {});
    }
  })
  if (showIndex == 0 && showNum > 1) {
    add++;
    var dom = '\
    <div class="swiper-slide">\
    <div class="slide_zoom_container row-all-center" style="height: '+ winH +'px">\
    <img class="swiper-lazy big_img_slide" data-src="'+ scrollObj.swiperArr[add].big_img +'" data-hash="'+ scrollObj.swiperArr[add].pic_hash +'" data-midSize="'+ scrollObj.swiperArr[add].middle_size +'"\
    data-time="'+ scrollObj.swiperArr[add].create_time +'" data-ori="'+ scrollObj.swiperArr[add].origin_img +'" data-oriSize="'+ scrollObj.swiperArr[add].pic_size +'" data-likeCount="'+ scrollObj.swiperArr[add].like_count +'" onload=loadOnePic(this)>\
    </div>\
    </div>';
    picShowSwiper.appendSlide(dom);
    picShowSwiper.update(true);
  } else if (showIndex == showNum - 1 && showNum > 1) {
    reduce--;
    var dom = '\
    <div class="swiper-slide">\
    <div class="slide_zoom_container row-all-center" style="height: '+ winH +'px">\
    <img class="swiper-lazy big_img_slide" data-src="'+ scrollObj.swiperArr[reduce].big_img +'" data-hash="'+ scrollObj.swiperArr[reduce].pic_hash +'" data-midSize="'+ scrollObj.swiperArr[reduce].middle_size +'"\
    data-time="'+ scrollObj.swiperArr[reduce].create_time +'" data-ori="'+ scrollObj.swiperArr[reduce].origin_img +'" data-oriSize="'+ scrollObj.swiperArr[reduce].pic_size +'" data-likeCount="'+ scrollObj.swiperArr[reduce].like_count +'" onload=loadOnePic(this)>\
    </div>\
    </div>';
    picShowSwiper.prependSlide(dom);
    picShowSwiper.update(true);
  } else if (showIndex != 0 && showIndex != showNum - 1 && showNum > 2) {
    add++;
    reduce--;
    var domPrev = '\
    <div class="swiper-slide">\
    <div class="slide_zoom_container row-all-center" style="height: '+ winH +'px">\
    <img class="swiper-lazy big_img_slide" data-src="'+ scrollObj.swiperArr[reduce].big_img +'" data-hash="'+ scrollObj.swiperArr[reduce].pic_hash +'" data-midSize="'+ scrollObj.swiperArr[reduce].middle_size +'"\
    data-time="'+ scrollObj.swiperArr[reduce].create_time +'" data-ori="'+ scrollObj.swiperArr[reduce].origin_img +'" data-oriSize="'+ scrollObj.swiperArr[reduce].pic_size +'" data-likeCount="'+ scrollObj.swiperArr[reduce].like_count +'" onload=loadOnePic(this)>\
    </div>\
    </div>';
    picShowSwiper.prependSlide(domPrev);
    picShowSwiper.update(true);
    var domNext = '\
    <div class="swiper-slide">\
    <div class="slide_zoom_container row-all-center" style="height: '+ winH +'px">\
    <img class="swiper-lazy big_img_slide" data-src="'+ scrollObj.swiperArr[add].big_img +'" data-hash="'+ scrollObj.swiperArr[add].pic_hash +'" data-midSize="'+ scrollObj.swiperArr[add].middle_size +'"\
    data-time="'+ scrollObj.swiperArr[add].create_time +'" data-ori="'+ scrollObj.swiperArr[add].origin_img +'" data-oriSize="'+ scrollObj.swiperArr[add].pic_size +'" data-likeCount="'+ scrollObj.swiperArr[add].like_count +'" onload=loadOnePic(this)>\
    </div>\
    </div>';
    picShowSwiper.appendSlide(domNext);
    picShowSwiper.update(true);
  }

  $('#imgShowModal').fadeIn().find('.imgShowSwiper').fadeIn();

  // 图片放大
  $('.slide_zoom_container').each(function(){
    new RTP.PinchZoom($(this), {});
  })

  // 点击记录hash
  picAjax("pic_click", thisHash);
}
// 关闭大图
function closeBigPicShow() {
  $(document).off('touchmove');
  $('video').removeClass('none');
  $('.common-loading').addClass('none');
  $('#imgShowModal').fadeOut(200,function() {
    picLikeArr = []; //关闭时清空 自己点赞过图片的数组
    getLikes(); // 重新获取一次；
    $('#imgShowModal .modal_footer').fadeIn();
    $('.imgShowSwiper .swiper-wrapper').empty();
    picShowSwiper.destroy(false,true);
  });
}
// 获得详情
function getDetail(ele, obj) {
  $.ajax({
    async: false,
    url: '/activity/live/detail',
    type: 'get',
    dataType: 'json',
    data: {activityNo: activityNo},
    success:function(data){
      if(data.success) {
        var result = data.result;
        var is_sell = result.is_sell;
        var back_img = result.back_img || false;
        pravite_password = result.serial_code;
        var pravite = (pravite_password && pravite_password !== '') ? true : false;

        // 是否有图文
        if ((is_sell & 512) > 0) {
          imageText.has = true;
          changeWaterfallToImageText();
        } else {
          $('.imgTextContainer').remove();
        }
        // 检测密码
        var cookie_password = getCookie('password');
        if (cookie_password && cookie_password == pravite_password) {
          $('.password-masking').remove();
          pravite = false;
          viewInterval(5);
        }
        setView(back_img, pravite);
        // 活动主会场
        getAllActivity(result);
        // banner
        if (result.head_img && result.head_img !== '') {
          $('#bannerImg').attr('src', result.head_img);
        } else {
          $('#bannerImg').remove();
          $('.banner').addClass('banner-noImg').html(result.name);
        }
        // banner跳转链接
        if (result.url && result.url !== '//') {
          $('.banner').attr('href', result.url);
          $('.bannerLink-tip').removeClass('none');
        }
        // 活动信息
        // 活动名称
        if (result.name && result.name !== '') {
          $('#mes-title').html(result.name);
        } else {
          $('#mes-title').parent().addClass('none');
        }
        // 日期时间
        $('#mes-date').parent().addClass('none');
        if (result.start_date && result.start_date !== '') {

          if (result.start_date === result.end_date) {
            $('#activityTime, #mes-time').html(result.start_date + '&nbsp;&nbsp;&nbsp;' + ifUndefine(result.start_time) + '~' + ifUndefine(result.end_time) );
          } else {
            $('#activityTime, #mes-time').html(result.start_date + ' ' + ifUndefine(result.start_time) + ' ~ ' + ifUndefine(result.end_date) + ' ' + ifUndefine(result.end_time) );
          }
        } else {
          $('#activityTime, #mes-time').parent().addClass('none');
        }

        // 地点
        if (result.place && result.place !== '') {
          $('#activityPlace, #mes-place').html(result.place);
        } else {
          $('#activityPlace, #mes-place').parent().addClass('none');
        }
        // 简介
        if (result.description && result.description !== '') {
          $('#activityDetail-p, #mes-intro').html(result.description);
        } else {
          $('#activityDetail-p, #mes-intro').parent().addClass('none');
        }
        // 其他信息配置
        var contractor_  = result.contractor ? JSON.parse(result.contractor) : false;
        if (contractor_) {
          for (var i = 0, len = contractor_.length - 1; i < len; i++) {
            var contractor_one = contractor_[i];
            var dom_ = '\
            <div class="mes-one row-start-start">\
              <span>'+ contractor_one.title +'</span>\
              <p id="mes-intro">'+ contractor_one.content +'</p>\
            </div>\
            ';
            $('#mesModal .mes-content').append(dom_);
          }
          var contractor_last = contractor_.slice(-1)[0];
          switch (contractor_last.type) {
            case 'show':
              $('.activityDetail').removeClass('none');
              $('.activityDetail-button').addClass('none');
              break;
            case 'none':
              $('.activityDetail-button, .activityDetail').addClass('none');
              break;
            default:
              $('.activityDetail').addClass('none');
              $('.activityDetail-button').removeClass('none');
          }
        }
        // 小伙伴状态
        var status_;
        if (result.status == 5) {
          status_ = "人正在等待收看此次图片直播";
          $('.loadMore').remove();
        } else if (result.status == 10) {
          status_ = "人正在收看此次图片直播";
        } else {
          status_ = "人已收看此次图片直播";
        }
        $('#lookStatus').html(status_);
        $('#lookNum').html(ifUndefine(result.view_count));
        // 直播状态
        if (result.status > 5) {
          getAllPics(ele, obj);
          if (imageText.has && imageText.bol) getImageTextPics();
        } else {
          $('.picLoadingBottom').css('height', '0');
          $('.picWait').removeClass('none');
        }
        // 是否有视频
        if (result.cc_room_id) {
          $('#videoWrapper').removeClass('none');
          ccLive(result.cc_room_id);
        }
        // 是否有iframe
        if (result.video_url && result.video_url !== '') {
          $('#videoWrapper').removeClass('none');
          $('.videoBox').addClass('none');
          $('.hasVideo-inner').append('<iframe id="iframeWH"></iframe>');
          whUrl = result.video_url;
        }
        // 自定义页面信息
        if ((is_sell & 1) <= 0) {
          // $('.relatedService, .homeLink').removeClass('none');
        }
        if ((is_sell & 256) <= 0) {
          // $('.relatedService, .bailujiLink').removeClass('none');
        }
        if ((is_sell & 2) <= 0) {
          $('.aboutPlus,.ewm,.download').removeClass('none');
        } else {
          $('#try').remove();
          $('.appointment').remove();
        }
        if ((is_sell & 2048) > 0) {
          var company_des = result.company_des;
          if (company_des.ad_type == 0) {
            $('#order').remove();
          } else {
            $('#try, .appointment').remove();
            $('.camer-name').html(company_des.ad_title);
            if (company_des.ad_type == 1) {
              $('.order-wrapper__form').remove();
              $('.order-wrapper__img').append('<img src="'+ company_des.ad_pic +'">').removeClass('none');
            }
            if (company_des.ad_type == 2) {
              company_des.ad_phone ? $('#camerPhone').html(company_des.ad_phone) : $('.camerPhone').remove();
            }
          }
        } else {
          $('.order, .order-wrapper').remove();
        }


        if ((is_sell & 4) > 0) {
          $('.logo').addClass('none');
        }
        if ((is_sell & 8) > 0) {
          document.title = result.name;
        }
        if ((is_sell & 1024) > 0) {
          document.title = result.definition_title ? result.definition_title : '';
        }
        if ((is_sell & 16) <= 0) {
          $('.me').css('height', '0');
        }
        if ((is_sell & 32) <= 0) {
          $('.findMe').css('height', '0');
        }
        if ((is_sell & 64) > 0) {
          $('#hot').removeClass('none');
        } else {
          $('.like-box').remove();
        }
        if ((is_sell & 128) > 0) {
          $('#timeLine').removeClass('none');
        }
        // 是否有前往主会场
        if (typeof result.father_activity_no === '' || result.father_activity_no === 0) {
          $('.jh-button').remove();
        } else {
          $('#go-jh').attr('href', 'http://' + host_+ '/activity/live?activityNo='+ result.father_activity_no);
        }
        // 更换皮肤
        changeTheme(ifUndefine(result.color));
        timeLine.theme = imageText.theme = ifUndefine(result.color);
        // 微信分享
        shareImgUrl = result.wx_img;
        sharedescContent = result.wx_desc;
        shareTitle = result.wx_title;
        changeShareLink();

      }
    }
  })
}
// 滚动时执行
function scrollAction() {
  var photoWrapper_height = $('.photoWrapper').outerHeight();
  var this_st = $document.scrollTop();
  whSt = this_st;
  // 加载图片
  if (this_st + winH > photoWrapper_height) {
    if (!isLoading && !isOver) {
      isLoading = true;
      loadMorePic(scrollEle, scrollObj);
      if (imageText.has && imageText.bol) scrollImageTextPics();
    }
    if (scrollEle === '.timeLine') {
      scrollTimeLinePics();
    }
  }
  // 相册悬浮
  if (this_st > albumNav_st) {
    $('.nav, .photoWrapper').addClass('float');
  } else {
    $('.nav, .photoWrapper').removeClass('float');
  }
}
// 滚动时加载图片
function loadMorePic(scrollEle, scrollObj){
  picStep = 30;
  $(scrollEle).find('.picLoadingBottom').animate({height: 50}, 200);
  picsWhere(scrollEle, scrollObj);
}
// 获取所有图片 每次只请求picstep30张
function getAllPics(ele, obj) {

  $.ajax({
    url: '/activity/live/pics',
    type: 'get',
    dataType: 'json',
    data: {
      activityNo: activityNo,
      picIndex: obj.theNew,
      isNew: false,
      count: 500,
    },
    success:function(data){
      if (data.success) {
        var picsArr = data.result.pics_array;
        if (picsArr.length > 0) {
          picAllNum = data.result.pics_total;

          $('#picCount').html(picAllNum);
          $('#lookNum').html(data.result.view_count);
          $('.picWait').addClass('none');

          obj.theNew = picsArr[picsArr.length - 1].pic_index;

          for (var i = 0, len = picsArr.length; i < len; i++) {
            obj.fixLocation.push(picsArr[i].small_img); //用于图片定位的数组
          }
          obj.preloadImg = obj.preloadImg.concat(picsArr);
          obj.swiperArr = obj.swiperArr.concat(picsArr);

          picsWhere(ele, obj);

          if (picsArr.length === 500) {
            getAllPics(ele, obj);
          } else {
            obj.theLast = obj.swiperArr[0].pic_index;
          }
          if (picAllNum === 0) {
            $('.picWait').removeClass('none');
          }
        } else {
          isOver = true;
        }
      } else {
        isOver = true;
      }
    }
  })
}
// 获得相应相册的图片
function getAlbumPics(ele, obj) {
  $.ajax({
    url: '/activity/live/album/one',
    type: 'get',
    dataType: 'json',
    data: {albumId: obj.id, picIndex: obj.theLast, count: 1000, isNew: obj.albumNew},
    success: function(data) {
      if (data.success && data.result.pics.length > 0) {
        obj.theLast = data.result.pics[0].pic_index;
        for (var i = 0, len = data.result.pics.length; i < len; i++) {
          obj.fixLocation.push(data.result.pics[i].small_img);
        }
        obj.preloadImg = data.result.pics.concat();
        obj.swiperArr = data.result.pics.concat();
        picsWhere(ele, obj);

      }
    }
  })
}
// 获取主办方及嘉宾
function getGuest() {
  $.ajax({
    async: false,
    url: '/activity/live/guest/list',
    type: 'get',
    dataType: 'json',
    data: {activityNo: activityNo},
    success:function(data){
      var result = data.result;
      // 是否有嘉宾
      if (data.success && typeof result.guest_list != 'undefined' && result.guest_list.length > 0) {

        var guestDom = '';
        for (var i = 0, len = result.guest_list.length; i < len; i++) {
          if (result.guest_list[i].type == 2) {
            var title_ = result.guest_list[i].title;
            var guestDom_one = '\
            <li class="sponsor" data-name="'+ ifUndefine(result.guest_list[i].name) +'" data-describe="'+ ifUndefine(result.guest_list[i].description) +'" data-qr="'+ result.guest_list[i].qr_code +'" data-logo="'+ result.guest_list[i].big_img +'" data-link="'+ result.guest_list[i].url +'">\
            <span class="sponsorTitle">'+ title_ +'</span>\
            <div class="sponsorBox row-all-center" style="background-image:url('+ result.guest_list[i].big_img +')">\
            <img src="http://static.qiezipai.cn/wechat/live/image/live4/border.png" class="sponsor-border none">\
            </div>\
            <span class="sponsorName">'+ ifUndefine(result.guest_list[i].name) +'</span>\
            </li>';
          } else {
            var guestDom_one = '\
            <li class="guest" data-name="'+ ifUndefine(result.guest_list[i].name) +'" data-describe="'+ ifUndefine(result.guest_list[i].description) +'" data-logo="'+ result.guest_list[i].big_img +'" data-qr="'+ result.guest_list[i].qr_code +'" data-logo="'+ result.guest_list[i].big_img +'" data-link="'+ result.guest_list[i].url +'">\
            <span class="guestTitle">嘉宾</span>\
            <div class="guestBox row-all-center" style="background-image:url('+ result.guest_list[i].big_img +')"></div>\
            <span class="guestName">'+ ifUndefine(result.guest_list[i].name) +'</span>\
            </li>';
          }
          guestDom += guestDom_one;
        }
        $('.guestInnerWrapper ul').append(guestDom);
        // 根据名字长度调为位置
        $('.sponsor .sponsorTitle').each(function() {
          var $this = $(this);
          if ($this.html().length === 4) {
            $this.addClass('sponsorTitle-four');
          } else if ($this.html().length === 0 || $this.html().length === 1) {
            $this.html('主办方');
          }
        })
      } else {
        $('.guestWrapper').addClass('none');
      }
      // 是否有品牌信息
      if (data.success && result.band_list.length > 0) {

        $('.logo').removeClass('logo-position');
        var customerDom = '';
        for (var i = 0, len = result.band_list.length; i < len; i++) {
          var customer_one = '\
          <div class="aboutCustomer">\
          <div class="title row-all-center">\
          <img src="http://static.qiezipai.cn/wechat/live/image/live4/title-icon.png" class="title-icon">\
          <span class="title-span"><span id="title-span">'+ result.band_list[i].name +'</span></span>\
          <img src="http://static.qiezipai.cn/wechat/live/image/live4/title-icon.png" class="title-icon">\
          </div>\
          '+ function() {if(result.band_list[i].description != '') {return '<p class="common-p" id="customer-p">'+ result.band_list[i].description +'</p>'} else {return '';}}() +
          function() {if(result.band_list[i].big_img != '' && result.band_list[i].big_img){return '<img src="'+ result.band_list[i].big_img +'" class="cusLogoImg">';} else {return '';}}() +
          function() {if(result.band_list[i].url && result.band_list[i].url != '//') {return '<a href="'+ result.band_list[i].url +'" class="cusWebSite row-all-center">前往相关页面&gt;</a>'} else {return '';}}() +
          '</div>';
          customerDom += customer_one;
        }
        $('#customerDefined').prepend(customerDom);

      }
    }
  })
}

// 相册
function getAlbum(){
  $.ajax({
    async: false,
    url: '/activity/live/albums',
    type: 'get',
    dataType: 'json',
    data: {
      activityNo: activityNo,
      count:1000
    },
    success:function(data){

      if (data.success && data.result.length > 0) {
        var result = data.result;

        for (var i = 0, len = result.length; i < len; i++) {
          var navLiDom = '\
          <li class="navLi row-all-center" data-id="'+ result[i].album_id +'">\
          <span class="navLi-span">'+ result[i].name +'</span>\
          <i class="btn-refresh btn-refresh-album none"></i>\
          </li>\
          ';
          var waterFallContainer = '\
          <div class="album'+ result[i].album_id +' block none">\
          <div class="picLoading picLoadingTop"></div>\
          <div class="picContainer row-start-center">\
          <div class="waterFallContainer">\
          <div class="picLeft"></div>\
          <div class="picRight"></div>\
          </div>\
          <div class="tiledContainer none"></div>\
          </div>\
          <div class="picLoading picLoadingBottom"></div>\
          <p class="loadMore mb32 none">没有更多了</p>\
          </div>';

          var album = {
            bol: true,
            albumNew: false,
            theLast: 0,
            preloadImg: [],
            fixLocation: [],
            swiperArr: [],
            newImgArr:[],
            leftHeight: 0,
            rightHeight: 0,
            id: result[i].album_id
          };
          albumArr.push(album);
          $('.nav ul').append(navLiDom);
          $('.nav li').last().insertBefore($('#no-use-li'));
          $('.photoWrapper').append(waterFallContainer);

          var logo_ = $('.all .logo').clone();
          var thisAlbum = $('.album' + result[i].album_id);
          var a = thisAlbum.find('.loadMore');
          thisAlbum.append(logo_);

        }
      }
    }
  })
}

function picsWhere(ele, obj){
  if (obj.preloadImg.length > 0 && picStep > 0) {
    var first_ = obj.preloadImg.shift(),
    picType_ = first_.pic_type,
    src_ = first_.small_img,
    hash_ = first_.pic_hash,
    bigSrc_ = first_.big_img,
    oriSrc_ = first_.origin_img,
    midsize_ = first_.middle_size,
    orisize_ = first_.pic_size,
    likeCount_ = first_.like_count,
    createTime_ = first_.create_time;
    picStep--;

    var isGif = first_.small_img.indexOf('.gif') > -1 ? '<img class="gifSign" src="http://static.qiezipai.cn/wechat/live/image/live4/gif.png">' : '';
    var unselected = timeLine.theme == 2 ? 'unselectedw' : 'unselected'; //无法选择时的图片样式 分黑白
    var oldPicSelect = puzzledCount >= 9 ? unselected : '';
    var oldSelectTag = puzzledCount >= 9 ? 'none' : '';
    var oldPicSelectShow = puzzledStatus ? '' : 'none';
    // 瀑布流
    var picTypeClass_ = '';
    if (picType_ === 1) {
      picTypeClass_ = 'picType1';
    } else if (picType_ === 2) {
      picTypeClass_ = 'picType2';
    } else {
      picTypeClass_ = 'picType3';
    }
    var picDom = '\
    <div class="pic_item picItem '+ picTypeClass_ +' new_pic" data-src="'+ src_ +'" data-time="'+ createTime_ +'" data-hash="'+ hash_ +'" data-big="'+ bigSrc_ +'" data-midSize="'+ midsize_ +'" data-ori="'+ oriSrc_ +'" data-oriSize="'+ orisize_ +'" data-likeCount="'+ likeCount_ +'" style="background-image:url('+ src_ +')">\
    '+ isGif +'\
    <div class="picSelect '+ oldPicSelect +' '+ oldPicSelectShow +'">\
    <span class="select-tag '+ oldSelectTag +'"></span>\
    </div>\
    </div>';

    var left = $(ele).find('.picLeft'), right = $(ele).find('.picRight');
    obj.leftHeight = left.height();
    obj.rightHeight = right.height();
    obj.leftHeight <= obj.rightHeight ? left.append(picDom) : right.append(picDom);

    // 平铺
    var tiledDom = '\
    <div class="pic_item picItem tiled_item new_pic" data-src="'+ src_ +'" data-time="'+ createTime_ +'" data-hash="'+ hash_ +'" data-big="'+ bigSrc_ +'" data-midSize="'+ midsize_ +'" data-ori="'+ oriSrc_ +'" data-oriSize="'+ orisize_ +'" data-likeCount="'+ likeCount_ +'" style="background-image:url('+ src_ +')">\
    '+ isGif +'\
    <div class="picSelect '+ oldPicSelect +' '+ oldPicSelectShow +'">\
    <span class="select-tag '+ oldSelectTag +'"></span>\
    </div>\
    </div>';
    var tiled = $(ele).find('.tiledContainer');
    tiled.append(tiledDom);

    if (timeLine.theme == 2) $('.select-tag').addClass('white'); //白色的拼图勾选

    picsWhere(ele, obj);
  } else {
    isLoading = false;
    logoPos2();
  }
  if (obj.preloadImg.length <= 0) {
    $(ele).find('.picLoadingBottom').addClass('none');
    setTimeout(function() {$(ele).find('.loadMore').slideDown();},500);
  };
}
// 新进入的图片 调用loadRefreshByOne > (loadPicTop + loadRefreshByOne[递归])
function refreshPics(ele, obj) {
  $(ele).find(".picLoadingTop").animate({height: 50}, 200);
  obj.newImgArr = [];
  $.ajax({
    url: '/activity/live/pics',
    type: 'get',
    dataType: 'json',
    data: {
      activityNo: activityNo,
      picIndex: obj.theLast,
      // picIndex: 0,
      isNew: true,
      count: 1000,
    },
    success:function(data){
      if (data.success) {
        var picArr = data.result.pics_array;
        picAllNum = data.result.pics_total;
        $('#picCount').html(picAllNum);
        commonSolovPics(picArr, ele, obj);
      }
    }
  })
}
function albumRefreshPics(ele, obj){
  obj.newImgArr = [];
  $.ajax({
    url: '/activity/live/album/one',
    type: 'get',
    dataType: 'json',
    data: {albumId: obj.id, picIndex: obj.theLast, count: 1000, isNew: obj.albumNew},
    success:function(data){
      if (data.success) {
        var picArr = data.result.pics;
        commonSolovPics(picArr, ele, obj);
      }
    }
  })
}
// 活动图片的链接数组
function commonSolovPics(picArr, ele, obj) {
  if (picArr.length < 1) {
    // hasNewPic_ = false;
    $(ele).find(".picLoadingTop").animate({height: 0}, 200);
    return false;
  } else {
    $(ele).find(".picLoadingTop").animate({height: 50},200);
    obj.theLast = picArr[0].pic_index;
    theRefreshNum = picArr.length;

    var swiperArr1 = [], fixLocationArr1 = [];
    for (var i = 0, len = picArr.length; i < len; i++) {
      obj.newImgArr.unshift(picArr[i]);
      swiperArr1.push(picArr[i]);
      fixLocationArr1.push(picArr[i].small_img);
    }
    obj.swiperArr = swiperArr1.concat(obj.swiperArr);
    obj.fixLocation = fixLocationArr1.concat(obj.fixLocation);
    loadRefreshByOne(ele, obj);
  }
}

function loadRefreshByOne(ele, obj){
  if (obj.newImgArr.length > 0) {
    theRefreshNum--
    var src_ = obj.newImgArr[0].small_img;
    var img_ = new Image();
    img_.src = src_;
    img_.onload = function() {
      addPicTop(ele, obj);
      loadRefreshByOne(ele, obj);
    }
    img_.onerror = function() {
      obj.newImgArr.shift();
      loadRefreshByOne();
    }
  } else {
    $(ele).find(".picLoadingTop").animate({height: 0}, 200);
    logoPos2();
  }
}
// 新图进入
function addPicTop(ele, obj) {
  // 从上加载 判断左右高度
  var first_ = obj.newImgArr.shift();
  obj.leftHeight = $(ele).find(".picLeft").height();
  obj.rightHeight = $(ele).find(".picRight").height();

  if (typeof first_.small_img != "undefined" || first_.small_img != "null") {
    // 瀑布流
    var isGif = first_.small_img.indexOf('.gif') > -1 ? '<img class="gifSign" src="http://static.qiezipai.cn/wechat/live/image/live4/gif.png">' : '';
    // 瀑布流
    var picTypeClass_ = ''
    if (first_.pic_type === 1) {
      picTypeClass_ = 'picType1';
    } else if (picTypeClass_ === 2) {
      picTypeClass_ = 'picType2';
    } else {
      picTypeClass_ = 'picType3';
    }

    var picDom = '\
    <div class="pic_item picItem '+ picTypeClass_ +' new_pic" data-src="'+ first_.small_img +'" data-time="'+ first_.create_time +'" data-hash="'+ first_.pic_hash +'" data-big="'+ first_.big_img +'" data-midSize="'+ first_.middle_size +'" data-ori="'+ first_.origin_img +'" data-oriSize="'+ first_.pic_size +'" data-likeCount="'+ first_.like_count +'" style="background-image:url('+ first_.small_img +')">\
    '+ isGif +'\
    <div class="picSelect none">\
    <span class="select-tag"></span>\
    </div>\
    </div>';
    obj.leftHeight <= obj.rightHeight ? $(ele).find('.picLeft').prepend(picDom) : $(ele).find('.picRight').prepend(picDom);

    // 平铺
    var tiledDom = '\
    <div class="pic_item picItem tiled_item new_pic" data-src="'+ first_.small_img +'" data-time="'+ first_.create_time +'" data-hash="'+ first_.pic_hash +'" data-big="'+ first_.big_img +'" data-midSize="'+ first_.middle_size +'" data-ori="'+ first_.origin_img +'" data-oriSize="'+ first_.pic_size +'" data-likeCount="'+ first_.like_count +'" style="background-image:url('+ first_.small_img +')">\
    '+ isGif +'\
    <div class="picSelect none">\
    <span class="select-tag"></span>\
    </div>\
    </div>';
    $(ele).find('.tiledContainer').prepend(tiledDom);

    if (timeLine.theme == 2) $('.select-tag').addClass('white');
  }
}
// 轮询新图
function picTimer() {
  refreshTimer = setInterval(function(){
    $.ajax({
      url: '/activity/live/pics',
      type: 'get',
      dataType: 'json',
      data: {
        activityNo: activityNo,
        picIndex: all.theLast,
        // picIndex: 0,
        isNew: true,
        count: 1000,
      },
      success:function(data){
        if (data.success) {
          $('#lookNum').html(data.result.view_count);
          if (data.result.pics_array.length > 0) {
            $('.picWait').addClass('none');
            $('.navLi').eq(0).find('.btn-refresh').removeClass('none');
          }
        }
      }
    })
  },30000);
}
// 统计点击量
function picAjax(value,hash_) {
  $.ajax({
    url: '/statistics/picClick',
    type: 'get',
    dataType: 'json',
    data: {key: value, params: hash_, activity_no: activityNo}
  })
}
// cc视频
function ccLive(roomid_) {
  $.ajax({
    url: '/activity/live/bokecc',
    type: 'get',
    dataType: 'json',
    data: {roomId:roomid_},
    success: function(data) {
      if (data.success) {
        var liveid_ = data.result.liveId;
        if (liveid_ && liveid_ == 'is_living') {
          $('.videoBox').removeClass('none').append('<div id="livePlayer"></div>')
          DWLive.init({
            userid: '33DAEE6345188E32',
            roomid: roomid_,
          });
        } else if (liveid_ && liveid_.length > 1){
          $('.videoBox').removeClass('none').append('<div id="playbackPlayer"></div>')
          $.DW.config({
            userId: '33DAEE6345188E32',
            roomId: roomid_,
            liveId: liveid_
          });
        }
      }
    }
  })
}

//swiper大图加载
function loadOnePic(ele) {
  var imgSrc_ = $(ele).attr('src');
  var img_ = new Image();
  img_.src = imgSrc_;
  img_.onload = function() {
    $(ele).parents('.swiper-slide').css('background', 'transparent');
  }
}
// 相册检测
function albumInterVal(thisnav, obj, id) {
  albumsInterval = setInterval(function() {
    $.ajax({
      url: '/activity/live/album/one',
      type: 'get',
      dataType: 'json',
      data: {albumId: id, picIndex: obj.theLast, count: 1000, isNew: obj.albumNew},
      success: function(data) {
        if (data.success && data.result.pics.length > 0) {
          thisnav.find('.btn-refresh').removeClass('none');
        }
      }
    })
  }, 30000);
}
// 判断powerby 位置
function logoPos2() {
  var w_h = $('.wrapper').height();
  w_h <= winH ? $('.logo').addClass('logo-position') : $('.logo').removeClass('logo-position');
}
// 获得热门图片
function getHotPics() {
    //$('.hot .picContainer').addClass('flex-wrap').html('');
    $('.hot .picContainer').addClass('flex-wrap');
    //$('.hot .picLoadingBottom').removeClass('none').animate({height: 50}, 200); 
    $('.hot .picLoadingBottom').addClass('none'); 
  //$('.hot .picContainer').css('height', winH);//auto
  
  //$.ajax({
  //  url: '/activity/live/album/like',
  //  type: 'get',
  //  dataType: 'json',
  //  data: {
  //    activityNo: activityNo,
  //    from: 0,
  //    size: 100,
  //  },
  //  success: function(data) {
  //    var pics = data.result.pics;
  //    var picsLength = data.result.pics.length;
  //    var picsArr = [];
  //    // console.log(data);
  //    if (data.success) {
  //      for (var i = 0; i < picsLength; i++) {
  //        hot.fixLocation.push(pics[i].small_img);
  //        if (i < 10) {
  //          bigTagArr.push(pics[i].pic_hash);
  //        }
  //      }
  //      solveHotPics(pics);
  //      hot.preloadImg = pics.concat();
  //      hot.swiperArr = pics.concat();
  //    }
  //  }
  //})

}
// 处理热门图片
function solveHotPics(pics) {
  for (var i = 0, len = pics.length; i < len && 100; i++) {
    var bigHot = '\
    <div class="hot-item-big hot-item fadeIn picItem" data-src="'+ pics[i].small_img +'" data-hash="'+ pics[i].pic_hash +'" data-big="'+ pics[i].big_img +'" data-midSize="'+ pics[i].middle_size +'" data-time="'+ pics[i].create_time +'" data-ori="'+ pics[i].origin_img +'" data-oriSize="'+ pics[i].pic_size +'"\
    data-likeCount="'+ pics[i].like_count +'">\
    <img src="'+ pics[i].big_img +'">\
    <div class="picSelect none">\
    <span class="select-tag"></span>\
    </div>\
    </div>';
    var smallHot = '\
    <div class="hot-item-small hot-item fadeIn picItem" data-src="'+ pics[i].small_img +'" data-hash="'+ pics[i].pic_hash +'" data-big="'+ pics[i].big_img +'" data-midSize="'+ pics[i].middle_size +'" data-time="'+ pics[i].create_time +'" data-ori="'+ pics[i].origin_img +'" data-oriSize="'+ pics[i].pic_size +'"\
    data-likeCount="'+ pics[i].like_count +'">\
    <div class="picSelect none">\
    <span class="select-tag"></span>\
    </div>\
    </div>';
    i < 2 ? $('.hot .picContainer').append(bigHot) : $('.hot .picContainer').append(smallHot);

    if (i < 2) {
      $('.hot-item').eq(i).append('<img class="no-sign-big" data-bigTag='+ i +' src="http://static.qiezipai.cn/wechat/live/image/live4/no'+ i +'.png">')
    } else if (i >= 2 && i < 10) {
      $('.hot-item').eq(i).append('<img class="no-sign-small" data-bigTag='+ i +' src="http://static.qiezipai.cn/wechat/live/image/live4/no'+ i +'.png">')
    }
  }

  $('.hot .picContainer').css('height', 'auto');
  $('.hot .logo').removeClass('none');
  hotLoad();
  $('.hot .picLoadingBottom').animate({height: 0},200).addClass('none');

  if (timeLine.theme == 2) $('.select-tag').addClass('white');
}
// 加载热门图片
function hotLoad() {
  if ($('.fadeIn').length > 0) {
    var $self = $('.fadeIn').eq(0);
    var img_ = new Image();
    img_.src = $self.attr('data-src');
    img_.onload = function() {
      $self.css('background-image', 'url('+ img_.src +')');
      $self.removeClass('fadeIn');
      hotLoad();
    }
    img_.onerror = function() {
      $self.remove();
      hotLoad();
    }
  }
}
// 获得点赞的hash数组
function getLikes() {
  $.ajax({
    url: '/activity/live/pic/like/info',
    type: 'get',
    dataType: 'json',
    data: {activityNo: activityNo},
    success: function(data) {
      if (data.success) {
        var picLike = data.result.picLike;
        for (var k in picLike) {
          picLikeArr.push(k);
        }
      }
    }
  })
}
// 点赞操作
function clickLikes() {
  var $this = $(this);
  var num = parseInt($('#like-num').html());
  var hash_ = $('#imgShowModal .swiper-slide-active img').attr('data-hash');
  var likeCount_ = $('#imgShowModal .swiper-slide-active img').attr('data-likeCount');
  if (!$this.hasClass('like-ani')) {
    num++;
    $('#like-num').html(num);
    likeStatus(num);

    $(scrollEle).find('.picItem').each(function() {
      var $this_ = $(this);
      var thisHash = $this_.attr('data-hash');
      if(thisHash == hash_) {
        $this_.attr('data-likeCount', num);
      }
    })
    iLike(hash_, 5);
  } else {
    num--;
    $('#like-num').html(num);

    likeStatus(num);
    //利用hash去获得列表中likecount的数量 方法不好 暂用
    $(scrollEle).find('.picItem').each(function() {
      var $this_ = $(this);
      var thisHash = $this_.attr('data-hash');
      var thisCount = $this_.attr('data-likeCount');
      if(thisHash == hash_) {
        $this_.attr('data-likeCount', --thisCount);
      }
    })
    iLike(hash_, -1);
  }
  $(this).toggleClass('like-ani');
}
// 点赞状态切换
function likeStatus(count) {
  if (count > 0) {
    $('#noLike').addClass('none');
    $('#hasLike').removeClass('none');
  } else {
    $('#hasLike').addClass('none');
    $('#noLike').removeClass('none');
  }
}
// 点赞请求
function iLike(hash_, status) {
  $.ajax({
    url: '/activity/live/pic/add/like',
    type: 'get',
    dataType: 'json',
    data: {
      picHash: hash_,
      status: status
    },
    success: function(data) {
      if (data.success) {
        status == 5 ? picLikeArr.push(hash_) : picLikeArr.splice($.inArray(hash_,picLikeArr),1);
      }
    }
  })
}
// 匹配自己是否点赞
function testLike(hash_) {
  picLikeArr.indexOf(hash_) > -1 ? $('.like').addClass('like-ani') : $('.like').removeClass('like-ani');
}
// 大图内是否有标识
function testBigTag(hash_) {
  $('.bigNoTag-big, .bigNoTag-small').remove();
  if (hotTab && bigTagArr.indexOf(hash_) > -1) {
    var no_ = bigTagArr.indexOf(hash_);
    no_ < 2 ? $('#imgShowModal').append('<img class="bigNoTag-big" src="http://static.qiezipai.cn/wechat/live/image/live4/no'+ no_ +'.png">') : $('#imgShowModal').append('<img class="bigNoTag-small" src="http://static.qiezipai.cn/wechat/live/image/live4/no'+ no_ +'.png">');
  }
}
// 单张分享按钮
function singleShare(event) {
  var bol = event.data.bol;
  if (bol) {
    var hash_ = $('#imgShowModal .swiper-slide-active img').attr('data-hash');
    $('#share').fadeIn();
    shareLink = 'http://'+ host_ +'/activity/live/pic/one/' + hash_;
  } else {
    $('#share').fadeOut();
    shareLink = window.location.href;
  }
  getRealLink();
  changeShareLink();
}
// 切换分享链接
function changeShareLink() {
  wx.ready(function() {
    wx.onMenuShareAppMessage({
      title: shareTitle , // 分享标题
      desc: sharedescContent, // 分享描述
      link: realShareLink, // 分享链接
      imgUrl: shareImgUrl, // 分享图标
      type: 'link', // 分享类型,music、video或link，不填默认为link
      dataUrl: '',
      success: function() {
        $.ajax({
          url: '/statistics/shareClick',
          type: 'GET',
          dataType: 'json',
          data: { key: UvUrl, params:"activityNo="+activityNo },
        });
      },
    });

    wx.onMenuShareTimeline({
      title: shareTitle, // 分享标题
      link: realShareLink, // 分享链接
      imgUrl: shareImgUrl,
      success: function() {
        $.ajax({
          url: '/statistics/shareClick',
          type: 'GET',
          dataType: 'json',
          data: {key: UvUrl,
            params: 'activityNo=' + activityNo
          },
        });
      },
    });
  })

}
// 请求原图
function requestOriPic() {
  $('.common-loading').removeClass('none');
  $('#imgShowModal .swiper-slide-active img').attr('data-getOri', 'yes');
  var oriSrc = $('#imgShowModal .swiper-slide-active img').attr('data-ori');
  var oriSize = $('#origin-picSize').html();
  var oriImg = new Image();
  oriImg.src = oriSrc;
  oriImg.onload = function() {
    $('#imgShowModal .swiper-slide-active img').attr('src', oriSrc);
    $('#picSize').html('目前大小' + oriSize.slice(3));
    $('#origin-picSize').addClass('none');
    $('.common-loading').addClass('none');
  }
}
// 控制显示隐藏一些元素
function removeEle(something, ele) {
  if (something == 'null' || !something || something == 'undefined' || something == '//') {
    $(ele).addClass('none');
  } else {
    $(ele).removeClass('none');
  }
}
// 引导页
function homeGuide() {
  if (homeGuide_ && homeGuide_ === 'false') {
    $('#guideModal').removeClass('none');
  } else {
    $('#guideModal').addClass('none');
  }
}
// 去除引导页cookie
function removeHomeGuide() {
  $(this).fadeOut(200);
  addWhUrl(3);
  $.ajax({
    url: '/home/guide/remove',
    type: 'get',
    dataType: 'json',
    data: {activityNo: activityNo}
  })
}
// 是否有主会场信息
function getAllActivity(result) {
  // 是否有前往主会场
  if (typeof result.father_activity_no === '' || result.father_activity_no === 0) {
    $('.jh-button').remove();
  } else {
    $('#go-jh').attr('href', 'http://' + host_+ '/activity/live?activityNo='+ result.father_activity_no);
    $('#title-jh').html(result.father_activity_name);

    if (result.father_activity_them !== 10) {
      for (var i = 0, len = result.activity_list.length; i < len; i++) {
        var resultList_ = result.activity_list[i];
        var status_ = resultList_.activity_status;
        var isGray = status_ === 5 ? 'grey' : '';
        var domb_ = '<a style="border:none;background-image:url('+ resultList_.little_img +')" href="'+ resultList_.activity_url +'" class="day_btn '+ isGray +' row-start-center" data-no="'+ resultList_.activity_no +'"></a>';
        $('.jh-box').append(domb_);
      }
    } else {
      for (var i = 0, len = result.activity_list.length; i < len; i++) {
        var resultList_ = result.activity_list[i];
        var status_ = resultList_.activity_status;
        var isActiveClass = status_ === 5 ? '' : 'active';
        var isActiveHtml = status_ === 5 ? '敬请期待' : '精彩图片';

        var domb_ = '\
        <a href="'+ resultList_.activity_url +'" class="day_btn row-start-center '+ isActiveClass +'" data-no="'+ resultList_.activity_no +'" style="border: 1px solid '+ resultList_.color +'">\
          <span class="day_title">'+ resultList_.title +'</span>\
          <span class="arrow_right '+ isActiveClass +'"><span style="color: ' + resultList_.color +'">'+ isActiveHtml +'</span><i class="iconfont icon-gengduo" style="color: ' + resultList_.color +'"></i></span>\
        </a>';
        $('.jh-box').append(domb_);
      }
      if (typeof result.color != 'undefined' && result.color != '') {
        setColor(result.color);
      }
    }
  }
}
// 找自己 悬浮
function findMeFloat() {
  $('.puzzle-cancel').trigger('click');
  if (findMeBol) {
    $('video').addClass('none');
    $('.find-container').removeClass('none');
    chooseImg('find');
    findMeBol = false;
    whModify();
  }
}
// 找自己 引导
function findMeGuide() {
  $('.pos-box').find('input').trigger('click');
  $('.find-container').fadeOut();
  $('video').removeClass('none');
}
// 上传图片
function chooseImg(id) {
	var key_name, url;
	var uploader = new findMeUp.uploader({
		runtimes: 'html5,flash,html4',    //上传模式,依次退化
		browse_button: id,       //上传选择的点选按钮，**必需**
		uptoken_url: '/base/getUploadToken',
		domain: 'http://s.plusx.cn',
		max_file_size: '6mb',           //最大文件体积限制
		max_retries: 3,                   //上传失败最大重试次数
		chunk_size: '0',                //分块上传时，每片的体积
		auto_start: true,
		multi_selection: true,
		// filters : {
		//     mime_types: [{title : "Image files", extensions : "jpg,gif,png,jpeg"},]
		// },                //选择文件后自动上传，若关闭需要自己绑定事件触发上传
    resize: {
      height: 800,
      crop: false,
      quality: 50,
      preserve_headers: true
    },
		init: {
			'UploadProgress': function() {
				$('.loading').removeClass('none');
			},
			'FileUploaded': function(up, file, info) {
				// var img_url;
				var res = JSON.parse(info);
				var hash_ = res.hash;
        // console.log(up, file);
				$.ajax({
					type: "get",
					url: "/home/pic/add",
					data: {
						url: key_name,
						hash: hash_,
						activityNo: activityNo
					},
					dataType: "json",
					success:function(data){
						$('.loading').addClass('none');
						window.location.href = '/page1/home/findme';
					},
					error:function(data){
						alert(data.message);
					}
				});
			},
			'Error': function(up, err, errTip) {
				var title = '上传图片过大';
				var mes = '上传照片大小超过4MB，请更换照片重新查找。';
				alertWindow(title, mes, '.alert-common');
			},
			'Key': function(up, file) {
				var myDate = new Date();
				var timestamp_ = (myDate.getMonth()+1).toString()+myDate.getDate().toString()+myDate.getHours().toString()+myDate.getMinutes().toString()+myDate.getSeconds().toString()+myDate.getMilliseconds().toString();
				var fliename_ = file.name.replace(/-/g,"_");
				var key_temp_ = '/plus/user/findme/' + user_id + '/' + timestamp_;
				key_name = key_temp_;
				return key_name;
			},
			'Destroy':function(up){}
		}
	});//uploader
}
// 点击出现聚合页入口
function gatherEntry() {
  $('video').toggleClass('none');
  $('.jh-container').fadeToggle();
  $('.jh-container-inner').toggleClass('active');
  $(this).toggleClass('active');
  whModify();
}
// 自定义聚合页活动条颜色等
function setColor(color_) {
  $('.day_btn').css('border', '1px solid ' + color_);
  $('.arrow_right').css('color', color_);
  $('#go-jh').css('color', color_);
}
// 设置主视觉
function setView(view, pravite) {
  if (view) {
    clickStart = true; // 有可能点击图片加入微吼
    var img_ = new Image();
    img_.src = view;
    img_.onload = function() {
      $('#main-view').css('background-image', 'url('+ view +')');
    }
    img_.onerror = function() {
      $('.main-masking').addClass('none');
    }
    setTimeout(function() {
      $('.masking').addClass('none');
    }, 1000)
    if (pravite) {
      clickPass = true; // 有可能点击密码加入微吼
      $('.password-masking').removeClass('none');
      $('body, html').addClass('overhidden');
      $('.password-wrapper').addClass('ani-fadeindown');
    } else {
      viewInterval(5);
    }
  } else {
    $('.main-masking').addClass('none');
    if (pravite) {
      clickPass = true; // 有可能点击密码加入微吼
      $('.password-masking').removeClass('none');
      $('body, html').addClass('overhidden');
      $('.password-wrapper').addClass('ani-fadeindown');
    }
    setTimeout(function() {
      $('.masking').addClass('none');
    }, 1000)
  }
}
// 主视觉倒计时
function viewInterval(second) {
  var viewInterval_ = setInterval(function() {
    if (second === 0) {
      $('.main-masking').fadeOut(1000);
      clearInterval(viewInterval_);
      addWhUrl(2);
    }
    $('.main-view-interval').html(second);
    second--;
  },1000)
}
// 开启或关闭拼图模式
function ifPuzzled(event) {
  var bol = event.data.bol;
  if (bol) {
    puzzledStatus = true;
    $(scrollEle).find('.picSelect').removeClass('none');
    $('.no-sign-big, .no-sign-small, .pos-box, .jh-button, .order, .try, .appointment').addClass('none');
    $('.puzzle-operate').removeClass('none');
  } else {
    puzzledStatus = false;
    $('.picSelect').addClass('none');
    $('.picSelect.selected, .select-tag.selected').removeClass('selected');
    $('.no-sign-big, .no-sign-small, .pos-box, .jh-button, .order, .try, .appointment').removeClass('none');
    $('.puzzle-operate').addClass('none');
    puzzledCount = 0;
    $('#puzzle-selected-count').html(puzzledCount).addClass('none');
    unPuzzled(false);
  }
}
// 选择将要拼图的图片
function selectPuzzlePic(event) {
  event.stopPropagation();
  var $this = $(this);
  if ($this.hasClass('unselected') || $this.hasClass('unselectedw')) {
    return;
  } else {
    $this.toggleClass('selected');
    $this.find('.select-tag').toggleClass('selected');
    puzzledCount = $('.picSelect.selected').length;
    if (puzzledCount > 0) {
      $('#puzzle-selected-count').removeClass('none').html(puzzledCount);
    } else {
      $('#puzzle-selected-count').addClass('none');
    }
    if (puzzledCount >= 9) {
      unPuzzled(true);
    } else {
      unPuzzled(false);
    }
  }
}
// 九张之后不可选择 样式变化
function unPuzzled(bol) {
  var lessPicSelect = $('.picSelect').not('.picSelect.selected');
  var unselected = timeLine.theme == 2 ? 'unselectedw' : 'unselected';

  if (bol) {
    lessPicSelect.addClass(unselected);
    lessPicSelect.find('.select-tag').addClass('none');
  } else {
    lessPicSelect.removeClass(unselected);
    lessPicSelect.find('.select-tag').removeClass('none');
  }
}
// 去拼图
function getPuzzle() {
  whModify();

  if (puzzledCount > 1) {
    $('.loading').removeClass('none');
    toast('正在处理拼图');

    var puzzledArr = [];
    $('.picSelect.selected').each(function() {
      var puzzle_hash = $(this).parent().attr('data-hash');
      puzzledArr.push(puzzle_hash);
    })
    var puzzledString = puzzledArr.toString();

    $.ajax({
      url: '/activity/live/pic/joint',
      type: 'get',
      dataType: 'json',
      data: {
        activityNo: activityNo,
        pic_hash: puzzledString
      },
      success: function(data) {
        // console.log(data);
        if (data.success) {
          var result = data.result;
          if (result.url && result.url !== '') {
            $('.puzzle-cancel').trigger('click');
            $('.puzzled-result-content').append('<img src="'+ data.result.url +'" class="puzzled-img">');
            $('.puzzled-result').removeClass('none');
          } else {
            toast('内部错误');
          }
        } else {
          toast('内部错误');
        }
        $('.loading').addClass('none');
      }
    })
  } else {
    toast('请至少选择两张图');
  }
}
// 关闭拼图弹窗
function closePuzzleAlert() {
  $('.puzzled-result').addClass('none');
  $('.puzzled-img').remove();
}
// 获取时间线图片总数
function getTimelinePics() {
  $('.timeLine .picLoading').removeClass('none');
  //$('.timeLine .picContainer').html('');
  $('.timeLine .picContainer').css('height', winH);
  timeLine.fixLocation = [];
  timeLine.swiperArr = [];
  timeLine.fixLocation = [];
  timeLine.count = 0;
  timeLine.add = 0;
  timeLine.data = [];
  $('.timeLine .picLoading').addClass('none');
  $('.timeLine .picContainer').css('height', 'auto');

  //$.ajax({
  //  url: '/activity/live/album/timeline',
  //  type: 'get',
  //  dataType: 'json',
  //  data: {
  //    activityNo: activityNo,
  //    from: 0,
  //    size: 2000
  //  },
  //  success: function(data) {
  //    if (data.success) {
  //      var result = data.result;
  //      if ((result instanceof Array) && (result.length > 0)) {
  //        timeLine.count = result.length;
  //        timeLine.data = result;
  //        for (var i = 0; i < result.length; i++) {
  //          for (var j = 0; j < result[i].picList.length; j++) {
  //            timeLine.fixLocation.push(result[i].picList[j].small_img);
  //          }
  //          timeLine.preloadImg = timeLine.preloadImg.concat(result[i].picList);
  //          timeLine.swiperArr = timeLine.swiperArr.concat(result[i].picList);
  //        }
  //        scrollTimeLinePics();
  //      }
  //      $('.timeLine .picLoading').addClass('none');
  //      $('.timeLine .picContainer').css('height', 'auto');
  //    }
  //  }
  //})

}
// 滚动加载时间线
function scrollTimeLinePics() {
  for (var i = 0; i < timeLine.step && timeLine.add < timeLine.count; i++) {
    var timeline_one = timeLine.data[timeLine.add];
    var timeLineTheme = timeLine.theme == 2 ? 'white' : '';
    var timeLineDom = '\
    <div class="timeLine-one col-start-start">\
      <div class="timeLine-one-inner '+ timeLineTheme +'"></div>\
      <div class="timeLine-one-outer">\
      <div class="timeLine-title row-start-center">\
        <span class="timeLine-dot '+ timeLineTheme +'">\
          <i class="timeLine-line"></i>\
        </span>\
        <span class="timeLine-time '+ timeLineTheme +'">'+ timeline_one.name +'</span>\
        <span class="timeLine-shrink '+ timeLineTheme +'"></span>\
      </div>\
      <div class="timeLine-picbox">\
        '+ function() {
          var timeline_picDomAll = '';
          for (var j = 0, j_len = timeline_one.picList.length; j < j_len; j++) {
            var timeline_picOne = timeline_one.picList[j];
            var src_ = timeline_picOne.small_img,
            hash_ = timeline_picOne.pic_hash,
            bigSrc_ = timeline_picOne.big_img,
            oriSrc_ = timeline_picOne.origin_img,
            midsize_ = timeline_picOne.middle_size,
            orisize_ = timeline_picOne.pic_size,
            likeCount_ = timeline_picOne.like_count,
            createTime_ = timeline_picOne.create_time,
            isGif = src_.indexOf('.gif') > -1 ? '<img class="gifSign" src="http://static.qiezipai.cn/wechat/live/image/live4/gif.png">' : '',

            unselected = timeLine.theme == 2 ? 'unselectedw' : 'unselected',
            oldPicSelect = puzzledCount >= 9 ? unselected : '',
            oldSelectTag = puzzledCount >= 9 ? 'none' : '',
            oldPicSelectShow = puzzledStatus ? '' : 'none';

            var timeline_picDom = '\
            <div class="pic_item picItem tiled_item new_pic" data-src="'+ src_ +'" data-time="'+ createTime_ +'" data-hash="'+ hash_ +'" data-big="'+ bigSrc_ +'" data-midSize="'+ midsize_ +'" data-ori="'+ oriSrc_ +'" data-oriSize="'+ orisize_ +'" data-likeCount="'+ likeCount_ +'" style="background-image:url('+ src_ +')">\
            '+ isGif +'\
            <div class="picSelect '+ oldPicSelect +' '+ oldPicSelectShow +'">\
            <span class="select-tag '+ oldSelectTag +'"></span>\
            </div>\
            </div>\
            ';
            timeline_picDomAll += timeline_picDom;
          };
          return timeline_picDomAll;
        }() +
      '</div>\
      </div>\
    </div>\
    ';
    $('.timeLine .picContainer').append(timeLineDom);
    if (timeLine.theme == 2) $('.select-tag').addClass('white');
    timeLine.add++; // 统计加载到第几个时间线模块
    $('.timeLine .picLoading').addClass('none');
  }
}
// 收缩时间线
function shrinkTimeLine() {
  var $this = $(this);
  $this.siblings('.timeLine-picbox').slideToggle();
  $this.find('.timeLine-shrink').toggleClass('unactive');
}
// 获得图文图片
function getImageTextPics() {
  $('.all .picLoading').css('height', '1rem');
  $('.imgTextContainer').html('');
  $('.imgTextContainer').css('height', winH);
  imageText.add = 0;
  imageText.count = 0;
  $.ajax({
    url: '/activity/live/album/timenote',
    type: 'get',
    dataType: 'json',
    data: {
      activityNo: activityNo,
      from: 0,
      size: 1000
    },
    success: function(data) {
      if (data.success) {
        var result = data.result;
        // console.log(result);
        if ((result instanceof Array) && (result.length > 0)) {
          imageText.data = result;
          imageText.count = result.length;

          scrollImageTextPics();
          $('.all .picLoading').css('height', '0');
        }
        $('.imgTextContainer').css('height', 'auto');
      }
    }
  })
}
function scrollImageTextPics() {
  for (var i = 0; i < imageText.step && imageText.add < imageText.count; i++) {
    var textimage_picOne = imageText.data[imageText.add];
    var imageTextTheme = imageText.theme == 2 ? 'white' : '';
    if (imageText.add === 0 && textimage_picOne.type === 1) {
      $('.imgTextContainer').append('<div class="imageText-area"></div>');
    }
    if (textimage_picOne.type == 1) {
      // 图文中的图
      var src_ = textimage_picOne.small_img,
      hash_ = textimage_picOne.pic_hash,
      bigSrc_ = textimage_picOne.big_img,
      oriSrc_ = textimage_picOne.origin_img,
      midsize_ = textimage_picOne.middle_size,
      orisize_ = textimage_picOne.pic_size,
      likeCount_ = textimage_picOne.like_count,
      createTime_ = textimage_picOne.create_time,
      isGif = src_.indexOf('.gif') > -1 ? '<img class="gifSign" src="http://static.qiezipai.cn/wechat/live/image/live4/gif.png">' : '',

      unselected = imageText.theme == 2 ? 'unselectedw' : 'unselected',
      oldPicSelect = puzzledCount >= 9 ? unselected : '',
      oldSelectTag = puzzledCount >= 9 ? 'none' : '',
      oldPicSelectShow = puzzledStatus ? '' : 'none';

      var textimage_picDom = '\
      <div class="pic_item picItem tiled_item new_pic" data-src="'+ src_ +'" data-time="'+ createTime_ +'" data-hash="'+ hash_ +'" data-big="'+ bigSrc_ +'" data-midSize="'+ midsize_ +'" data-ori="'+ oriSrc_ +'" data-oriSize="'+ orisize_ +'" data-likeCount="'+ likeCount_ +'" style="background-image:url('+ src_ +')">\
      '+ isGif +'\
      <div class="picSelect '+ oldPicSelect +' '+ oldPicSelectShow +'">\
      <span class="select-tag '+ oldSelectTag +'"></span>\
      </div>\
      </div>\
      ';
      $('.imageText-area').last().append(textimage_picDom);
    } else {
      // 图文中的文
      var title_ = textimage_picOne.title;
      var word_ = textimage_picOne.note;
      var time_ = textimage_picOne.relate_time;
      var textDom = '\
      <section class="text_item">\
        <p class="row-start-center"><span class="imageText-title-tag row-start-center"><i class="imageText-title-tag1 '+ imageTextTheme +'"></i><i class="imageText-title-tag2 '+ imageTextTheme +'"></i></span><span class="imageText-title '+ imageTextTheme +'">'+ title_ +'</span></p>\
        <p class="imageText-word '+ imageTextTheme +'">'+ word_ +'</p>\
        <p class="imageText-time '+ imageTextTheme +'">'+ time_ +'</p>\
      </section>\
      ';
      $('.imgTextContainer').append(textDom);
      $('.imgTextContainer').append('<div class="imageText-area"></div>');
    }
    imageText.add++;
  }
}

// 图文与四列切换 仅在有图文的时候执行
function changeWaterfallToImageText () {
  imageText.bol = true;
  $('.changeStyle span').removeClass('active');
  $('.changeStyle span').eq(1).addClass('active');
  $('.waterFallContainer').css('width', '0');
  $('.waterFallContainer').find('.picLeft').addClass('none');
  $('.waterFallContainer').find('.picRight').addClass('none');
  $('.tiledContainer').removeClass('none');
  $('.fourImageContainer').eq(0).removeClass('none');
  $('.fourImageContainer').eq(1).addClass('none');
}
// 密码验证
function praviteVerify() {
  if (!$('#password-enter').hasClass('active')) {
    $('#password-enter').addClass('active');
    var password_ = $.trim($('#password').val());
    password_ = $.md5(password_);
    if (password_ == pravite_password) {
      setCookie('password', pravite_password);
      $('.password-wrapper').addClass('ani-fadeoutdown');
      $('.password-masking').fadeOut(1200, function() {
        $(this).remove();
      });
      setTimeout(function() {
        $('body, html').removeClass('overhidden');
      }, 1000)
      viewInterval(5);

      addWhUrl(1);

    } else {
      toast('密码错误!');
      $('#password-enter').removeClass('active');
      $('#password').focus();
    }
  }
}

// 适配微吼视频出现在视口内 页面上滚
function whModify() {
  if (whSt <= albumNav_st && whUrl) {
    $('body').animate({scrollTop: albumNav_st}, 400);

  }
}
// 判断 插入微吼链接的时机
function addWhUrl(n) {
  switch (n) {
    case 1:
    if (clickPass && !clickGuide && !clickStart) {
      $('#iframeWH').attr('src', whUrl);
    };
    break;
    case 2:
    if (clickStart && !clickGuide) {
      $('#iframeWH').attr('src', whUrl);
    };
    break;
    case 3:
    if (clickGuide) {
      $('#iframeWH').attr('src', whUrl);
    }
    break;
    case 4:
    if (!clickGuide && !clickPass && !clickStart) {
      $('#iframeWH').attr('src', whUrl);
    }
  }
}
